{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>question_id</th>\n",
       "      <th>question_title</th>\n",
       "      <th>question_detail</th>\n",
       "      <th>tag_ids</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>为什么有的孩子就比同龄的孩子机灵，知道该讨好谁，知道谁比较好说话啊？还知道怎样做不会惹老师生气？</td>\n",
       "      <td>小学的孩子，知道看眉眼高低，懂得老师生气的时候就尽量躲着点？问过家长在家有没有特别教过，家长...</td>\n",
       "      <td>967|8922|240|396</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>怎么看待男朋友说玩游戏顺手带妹？</td>\n",
       "      <td>跟男朋友谈了一年左右，刚开始知道他喜欢玩游戏，他说他不带妹，后来暑假刚开始，他疯狂的泡在游戏...</td>\n",
       "      <td>69|109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>武林人士退隐江湖之后会过着怎样的生活？</td>\n",
       "      <td>欢迎各种脑洞~</td>\n",
       "      <td>35|211|230|61|1157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>“一见倾心，再见依然。”这个句子的唯美英文翻译？求大神解答！</td>\n",
       "      <td>NaN</td>\n",
       "      <td>475|15392|2163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>如何看待加拿大国际数学奥林匹克竞赛团队都是华人？</td>\n",
       "      <td></td>\n",
       "      <td>6803|446|3216|4079|930</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   question_id                                    question_title  \\\n",
       "0            0  为什么有的孩子就比同龄的孩子机灵，知道该讨好谁，知道谁比较好说话啊？还知道怎样做不会惹老师生气？   \n",
       "1            1                                  怎么看待男朋友说玩游戏顺手带妹？   \n",
       "2            2                               武林人士退隐江湖之后会过着怎样的生活？   \n",
       "3            3                    “一见倾心，再见依然。”这个句子的唯美英文翻译？求大神解答！   \n",
       "4            4                          如何看待加拿大国际数学奥林匹克竞赛团队都是华人？   \n",
       "\n",
       "                                     question_detail                 tag_ids  \n",
       "0  小学的孩子，知道看眉眼高低，懂得老师生气的时候就尽量躲着点？问过家长在家有没有特别教过，家长...        967|8922|240|396  \n",
       "1  跟男朋友谈了一年左右，刚开始知道他喜欢玩游戏，他说他不带妹，后来暑假刚开始，他疯狂的泡在游戏...                  69|109  \n",
       "2                                            欢迎各种脑洞~      35|211|230|61|1157  \n",
       "3                                                NaN          475|15392|2163  \n",
       "4                                                     6803|446|3216|4079|930  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_df = pd.read_csv('../data/train.csv')\n",
    "train_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>target</th>\n",
       "      <th>text</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>IphoneSE</td>\n",
       "      <td>讲真，对iphoneSE很心动，但是又很期待iphone7，心塞</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>春节放鞭炮</td>\n",
       "      <td>传统春节来临传统的拜神，放鞭炮，烧纸，热闹呢</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>俄罗斯在叙利亚的反恐行动</td>\n",
       "      <td>俄罗斯在战争状态下的紧急动员能力，这不是土耳其可以低估的。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>深圳禁摩限电</td>\n",
       "      <td>珠海要是有这么高强度，市区就不会有那么多摩托车横冲直撞了</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>深圳禁摩限电</td>\n",
       "      <td>#深圳禁摩限电# 早该整了，快递开电车，真把马路当成他们家开的一样...不过他们工作压力大，...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         target                                               text\n",
       "0      IphoneSE                   讲真，对iphoneSE很心动，但是又很期待iphone7，心塞\n",
       "1         春节放鞭炮                             传统春节来临传统的拜神，放鞭炮，烧纸，热闹呢\n",
       "2  俄罗斯在叙利亚的反恐行动                      俄罗斯在战争状态下的紧急动员能力，这不是土耳其可以低估的。\n",
       "3        深圳禁摩限电                       珠海要是有这么高强度，市区就不会有那么多摩托车横冲直撞了\n",
       "4        深圳禁摩限电  #深圳禁摩限电# 早该整了，快递开电车，真把马路当成他们家开的一样...不过他们工作压力大，..."
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# test_df = pd.read_csv('../data/test.csv', sep='\\t')\n",
    "# test_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# question_title"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "138\n"
     ]
    }
   ],
   "source": [
    "texts = train_df.question_title.tolist()\n",
    "max_len = 0\n",
    "df_len_list = []\n",
    "for i in range(len(texts)):\n",
    "    text = []\n",
    "    text = texts[i]\n",
    "    df_len_list.append(len(text))\n",
    "    max_len = max(max_len, len(text))\n",
    "print(max_len)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "70"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted_len = sorted(df_len_list)\n",
    "sorted_len[int(len(sorted_len)*0.999)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# question_detail"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4061\n"
     ]
    }
   ],
   "source": [
    "texts = train_df.question_detail.tolist()\n",
    "max_len = 0\n",
    "df_len_list = []\n",
    "for i in range(len(texts)):\n",
    "    text = []\n",
    "    text = texts[i]\n",
    "    if pd.notnull(text):\n",
    "        df_len_list.append(len(text))\n",
    "        max_len = max(max_len, len(text))\n",
    "print(max_len)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2600"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted_len = sorted(df_len_list)\n",
    "sorted_len[int(len(sorted_len)*0.999)]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
